package com.day1;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Servlet2 extends HttpServlet{
    public Servlet2() {
        System.out.println("nnn");
    }

    @Override
    public void init() throws ServletException {
        System.out.println("xikexiu");
    }

    @Override
    public void destroy() {
        System.out.println("kounolie");
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.service(req, resp);
        resp.setContentType("text/html;charset=utf-8");
        String name=req.getParameter("username");

        resp.getWriter().print("你好："+name);
        System.out.println("ffff");
        String[] hobbies = req.getParameterValues("hobby");
        resp.getWriter().print("我的爱好是：");
        for (String hobby:hobbies){
            resp.getWriter().print(hobby);
        }

    }
}
